package com.lanlian.cayman.view;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;

import com.lanlian.cayman.R;
import com.lanlian.utillib.DisplayUtil;

/**
 * <pre>
 *     author : huxiaobo
 *     e-mail : huxiaobo@xlanlian.com
 *     date   : 2018/9/6 19:56
 *     desc   : todo
 *     version: 1.0
 * </pre>
 */
public class ShowPictureDialog extends Dialog {

    private Context mContext;
    private int mPicId;
    private ImageView mImg;
    private ImageView mImgClose;

    public ShowPictureDialog(@NonNull Context context, int picId) {
        super(context, R.style.customDialog);
        this.mContext = context;
        this.mPicId = picId;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_show_picture);
        Window window = getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        lp.width = (int) (DisplayUtil.getScreenWidth(mContext) * 0.8);
        lp.height = (int) (DisplayUtil.getScreenHeight(mContext) * 0.7);
        window.setAttributes(lp);
        mImg = findViewById(R.id.img);
        mImgClose = findViewById(R.id.img_close);
        mImg.setImageResource(mPicId);
        mImgClose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

}
